package com.example.delicioushunter.view.activity;

import com.example.delicioushunter.R;
import com.example.delicioushunter.control.supportcontrol.DHSharedPreference;

import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View.OnClickListener;
import android.view.Menu;
import android.view.View;
import android.widget.Toast;
import android.widget.ToggleButton;

public class UserSettingActivity extends Activity {

	private ToggleButton toggleSignature;
	private Context mContext;
	DHSharedPreference settings;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mContext = this;
		setContentView(R.layout.activity_user_setting);
		
		toggleSignature = (ToggleButton) findViewById(R.id.toggleSignature);
		toggleSignature.setOnClickListener(toggleSignatureClick);
		settings = new DHSharedPreference(getApplicationContext());
		toggleSignature.setChecked(settings.getSignature());
	}
	
	OnClickListener toggleSignatureClick = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			String mychoice = toggleSignature.getText().toString();
			if(mychoice.equalsIgnoreCase("On")){
				settings.setSignature(true);
				Intent intent = new Intent(UserSettingActivity.this, SignatureRegistrationActivity.class);
				intent.putExtra("ACTION", "Registration");
				startActivity(intent);
			}
			else if(mychoice.equalsIgnoreCase("Off"))
				settings.setSignature(false);
		}
	};

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.user_setting, menu);
		return true;
	}

}
